package com.hup.utils.io.batch.function;

import com.hup.utils.io.batch.BaseBatch;
import com.hup.utils.io.batch.SimpleBatchResp;

import java.util.ArrayList;

/**
 * @author hugan
 * @date 2020/4/2
 */
public class TaskKill implements BaseBatch<SimpleBatchResp> {

    private String exeName;

    public TaskKill(String exeName) {
        this.exeName = exeName;
    }

    @Override
    public String cmd() {
        return "taskkill /f /im " + exeName;
    }

    @Override
    public String desc() {
        return "关闭[" + exeName + "]进程";
    }

    @Override
    public SimpleBatchResp parse(ArrayList<String> lstResp) {
        if (lstResp.get(0).contains("错误")) {
            return SimpleBatchResp.fail(this, lstResp.get(1));
        }
        return SimpleBatchResp.success();
    }
}
